# insert your desired path in the parenthesis and remove the #
# setwd("/your/working/directory/goes/here") Lab 2
DATA 202 - Alexander - Fall 2023
For Lab 2, you may submit your solutions to Canvas as a .pdf or an R Script or even as a .txt file.
Please see the Preparing Lab Reports at the bottom of the lab 1 assignment.
Learning Objectives
The Lab 2 assignment focuses on you exploring any two variables located in one of the data frames in the critstats package or in gss_cat. You will also return to some of the functions we have used before to clean variables and manipulate data frames. Your analyses in this lab should focus on a bivariate analysis between two categorical variables, two numeric variables, or one numeric variable and one categorical variable.
Please note: you should not use the same variables from a previous assignment but you may use the same data set.
Learning Activities
By the end of this lab you will be able to:
- Locate data sets in the
critstatspackage, or usegss_cat - Develop an original research question
- Clean and manipulate data for analysis
- Examine the relationship between two variables
You should submit your final output on Canvas here.
Part 0: Pre-lab tasks
Create a new project called
stats-pt3Check your working directory
Start a new R Script
Write a preamble
Install and/or update packages and load libraries
Task 0.1: Create a new projec called stats-pt3
In your R session, navigate to: File > New Project. Create a new project called stats-pt3.
Task 0.2: Check your working directory
Check your working directory by typing getwd().
If you are not in the desired directory, you can change your directory using the associated path. This path should be the same as the project folder that you plan to work out of for the next several weeks.
For example, stats-pt3/lab2.
You can add a new sub-folder manually or under the Files tab in the RStudio IDE.
Task 0.3: Start a new file in your session
Once you have confirmed that you are in the correct directory, start a new R Script.
Task 0.4: Write a preamble
## Name: <include your full name>
## Assignment: Lab 2
## Date: <here you may want to add a date>
## Purpose: <insert the goals or purpose of the RScript>Task 0.5: Packages and libraries
# install the tidyverse package
install.packages("tidyverse", repos = "http://cran.us.r-project.org")
# load the libraries needed for today's analyses
library(tidyverse)
library(dplyr)
library(critstats)
## update packages if needed; remove # to run code
# update.packages("package-name")Part 1:
In this part of the lab, you should complete the following tasks:
Locate a data sets in the
critstatspackage or ingss_catDevelop an original research question on two variables in your data set
Part 2:
In this part of the lab, you should complete the following tasks:
Clean and manipulate your data for analysis
Examine the relationship between two variables
Part 1 Reports
Report 1.1
What data set have you decided to use?
Report 1.2
Which two variables from your data set will be analyzed?
Report 1.3
What is your research question?
Report 1.4
What is your data analysis plan? Please be descriptive.
Report 1.5
What are some potential limitations for your analysis?
Part 2 Reports
Report 1.6
Does your data contain missing values? If so, how have you dealt with these values?
Report 1.7
Please include all code used to clean and manipulate the variables.
Report 1.8
What relationship, if any, exists between the two variables?
Report 1.9
How do these findings relate to your research question and theory?
Report 1.10
What limitations exist as a result of the data analysis?
Experiencing issues?
If you experience issues executing your code, it is likely that you have made an error in the previous steps.
Remember that R is case sensitive in all instances, and space sensitive in some instances.
Please be sure to go back and carefully check your code.
You can also leave a comment on the Lab Discussion Board or in our course Slack channel.